

public class test28 {

    //定义一个方法判断数组中某一个数是否存在,将结果返回给调用处
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5};
        boolean flag = contains(arr, 3);
        System.out.println(flag);
    }
        public static boolean contains ( int[] arr, int number){
            for (int i = 1; i < arr.length; i++) {
                if (arr[i] == number) {
                   return true;
                }
            }
            return false;
        }
    }
